package cn.snmp.mutual.org.opennms.protocols.snmp;

import java.io.*;

import cn.snmp.mutual.org.opennms.protocols.snmp.asn1.AsnDecodingException;
import cn.snmp.mutual.org.opennms.protocols.snmp.asn1.AsnEncoder;
import cn.snmp.mutual.org.opennms.protocols.snmp.asn1.AsnEncodingException;

public class SnmpNull implements SnmpSyntax, Cloneable, Serializable {
    static final long serialVersionUID = 441279481529521581L;
    public static final byte ASNTYPE = 5;

    public SnmpNull() {
    }

    public SnmpNull(final SnmpNull second) {
    }

    public byte typeId() {
        return 5;
    }

    public int encodeASN(final byte[] buf, final int offset, final AsnEncoder encoder) throws AsnEncodingException {
        return encoder.buildNull(buf, offset, this.typeId());
    }

    public int decodeASN(final byte[] buf, final int offset, final AsnEncoder encoder) throws AsnDecodingException {
        final Object[] rVals = encoder.parseNull(buf, offset);
        if ((byte) rVals[1] != this.typeId()) {
            throw new AsnDecodingException("Invalid ASN.1 type");
        }
        return (int) rVals[0];
    }

    public SnmpSyntax duplicate() {
        return new SnmpNull(this);
    }

    public Object clone() {
        return new SnmpNull(this);
    }

    @Override
    public String toString() {
        return "SNMP Null";
    }
}
